package triannon.client.sprites;

import org.jdom.Element;

import triannon.client.interfaces.IXML;

public class SpriteInfo implements IXML {
	private String key;
	private int width;
	private int height;
	private int originX;
	private int originY;

	private AnimationMap animations;
	private final SpriteType spriteType;

	public SpriteInfo(SpriteType spriteType, Element element) {
		this.spriteType = spriteType;
		parseXML(element);
	}

	@Override
	public void parseXML(Element element) {
		String s = element.getAttributeValue("key");
		key = s;

		s = element.getAttributeValue("width");
		width = Integer.valueOf(s);

		s = element.getAttributeValue("height");
		height = Integer.valueOf(s);

		s = element.getAttributeValue("originX");
		originX = Integer.valueOf(s);

		s = element.getAttributeValue("originY");
		originY = Integer.valueOf(s);

		animations = new AnimationMap(spriteType, key, element);
	}

	public String getKey() {
		return key;
	}

	public AnimationMap getAnimations() {
		return animations;
	}

	public int getWidth() {
		return width;
	}

	public int getHeight() {
		return height;
	}

	public int getOriginX() {
		return originX;
	}

	public int getOriginY() {
		return originY;
	}

	@Override
	public Element toXML() {
		throw new UnsupportedOperationException("Xml output not supported");
	}
}
